package regexppractice;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @description:
 * @author: jhy
 * @time: 2021/6/1 15:27
 */

//分组、捕获、反向引用
public class RegExpDemo7 {

    public static void main(String[] args) {

        String content = "112233522511111";
        //匹配两个连续相同的数字
        //String regStr = "(\\d)\\1";

        //匹配五个连续相同的数字
        //String regStr = "(\\d)\\1{4}";

        //匹配四位数，要求第一位与第四位相同，第二位与第三位相同
        String regStr = "(\\d)(\\d)\\2\\1";
        Pattern pattern = Pattern.compile(regStr);
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()){
            System.out.println("匹配到："+matcher.group(0));
        }
    }
}
